var cookieName = 'show_bet_slip';

$(document).ready(function(){
    if(getCookie(cookieName) === undefined || getCookie(cookieName) === 'false'){
        show_bet_slip(false);
    }else{
        show_bet_slip(true);
    }
    $('#cbBetSlip').click(function(){
        show_bet_slip(this.checked);
    });
})

function show_bet_slip(val){
    setCookie(cookieName, val);
    if(val === true){
        $('#cbBetSlip').attr('checked', 'checked');
        $('.bet_slip').show();
    }else{
        $('#cbBetSlip').attr('checked', false);
        $('.bet_slip').hide();
    }
}

function setCookie(key, value) {
    var expires = new Date();
    expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
    document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}

function getCookie(key) {
    var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
    return keyValue ? keyValue[2] : null;
}